<html>
<head>
    <meta charset="utf-8"/>
    <title>信创WEB中间件替换</title>
    <script src="jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#showTime").text(new Date());
            if (!window.localStorage) {
                return;
            }
            // 本地缓存回显
            $("#srcJarPath").val(localStorage.getItem("srcJarPath"));
            $("#licenseAndConfigPath").val(localStorage.getItem("licenseAndConfigPath"));
            $("#embedPath").val(localStorage.getItem("embedPath"));
            $("#embedReactorPath").val(localStorage.getItem("embedReactorPath"));
        });

        function repackage() {
            let srcJarPath = $("#srcJarPath").val();
            if(!srcJarPath){
                alert("原Jar包路径不能为空！")
                return false;
            }
            localStorage.setItem("srcJarPath", srcJarPath);

            let licenseAndConfigPath = $("#licenseAndConfigPath").val();
            if(!licenseAndConfigPath){
                alert("证书与配置模板路径不能为空！")
                return false;
            }
            localStorage.setItem("licenseAndConfigPath", licenseAndConfigPath);

            let embedPath = $("#embedPath").val();
            if(!embedPath){
                alert("嵌入式tongweb-lib路径不能为空！")
                return false;
            }
            localStorage.setItem("embedPath", embedPath);

            let embedReactorPath = $("#embedReactorPath").val();
            if(!embedReactorPath){
                alert("嵌入式tongweb-reactor-lib路径不能为空！")
                return false;
            }
            localStorage.setItem("embedReactorPath", embedReactorPath);
            $.ajax({
                type: 'GET',
                url: '/repackage?srcJarPath=' + encodeURI(srcJarPath)
                    + "&licenseAndConfigPath=" + encodeURI(licenseAndConfigPath)
                    + "&embedPath=" + encodeURI(embedPath)
                    + "&embedReactorPath=" + encodeURI(embedReactorPath),
                success: function () {
                    alert("请求成功，请在后台日志查看执行状态！");
                },
            });
            $("#showTime").text(new Date());
        }
    </script>
    <style>
        input[type='text'] {
            width: 800px;
        }
    </style>
</head>
<body>
<div style="position: relative; top: 20px;">
    <div id="showTime"></div>
    <FORM onsubmit="return false;">
        <label for="srcJarPath">原Jar包路径:</label>
        <input type="text" id="srcJarPath" name="srcJarPath" required>
        <br>

        <label for="licenseAndConfigPath">证书与配置模板路径:</label>
        <input type="text" id="licenseAndConfigPath" name="licenseAndConfigPath" required>
        <br>

        <label for="embedPath">嵌入式tongweb-lib路径:</label>
        <input type="text" id="embedPath" name="embedPath" required>
        <br>

        <label for="embedReactorPath">嵌入式tongweb-reactor-lib路径:</label>
        <input type="text" id="embedReactorPath" name="embedReactorPath" required>
        <br>

        <!-- 提交按钮 -->
        <input type="submit" value="提交" onclick="repackage()">
    </FORM>
</div>
</body>
</html>
